package org.springblade.modules.repair.vo;

import com.alibaba.fastjson2.JSONArray;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.modules.repair.entity.*;
import org.springblade.modules.repair.enums.*;
import org.springblade.modules.repair.vo.part.PartWordUrlVo;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Date 14:14 2022/7/1
 * @Description {
 *   部件更换详情
 * }
 * @Author lsay
 **/
@Data
public class PartsWorkDetailVO {

	@JsonSerialize(using = ToStringSerializer.class)
	private Long planId;

	@JsonSerialize(using = ToStringSerializer.class)
	private Long elevatorId;

	private String processInstanceId;

	private String detailTitle;

	private Integer status;

	private String statusName;

	private String auditStatusName;

	private String buildingName;

	private String elevatorAddress;

	@JsonSerialize(using = ToStringSerializer.class)
	private Long createUser;

	/**
	 * 申请人名称
	 */
	private String createUserName;

	/**
	 * 申请时间
	 */
	private Date createTime;

	/**
	 * 关联维修任务详情
	 */
	private CorrelationMalfunctionDetailVO malDetailVO;

	/**
	 * 最近一次任务
	 */
	private LastPlanVO lastPlanVO;

	/**
	 * 维修操作记录
	 */
	private List<MalFunctionHistoryVO> malFunctionHistories;

	/**
	 * 关联任务的用户
	 */
	private List<MaintainPlanContentUser> planContentUsers;

	/**
	 * 流程审批节点flow
	 */
	private BladeFlow taskFlow;

	/**
	 * 紧急程度
	 */
	private Integer emerProcType;

	/**
	 * 工单类型
	 */
	private Integer workOrderType;

	/**
	 * 紧急程度描述
	 */
	private String emerProcTypeName;

	/**
	 * 工单类型描述
	 */
	private String workOrderTypeName;

	/**
	 * 审批状态
	 */
	private Integer auditStatus;

	/**
	 * 审批id
	 */
	private Long approveId;

	private ElevatorAttachmentHistory elevatorAttachmentHistory;

	/**
	 * 2025-06 当前工单ext信息，用于暂存elevatorAttachmentHistory的铭牌信息
	 */
	@ApiModelProperty("工单拓展信息")
	private MaintainPlanContentExt maintainPlanContentExt;

	/**
	 * 2025-06 新增单位名称字段
	 */
	@ApiModelProperty("单位名称")
	private String unitNameValue;


	/**
	 * 配件收货地址
	 */
	private PartAddress partAddress;

	private List<MaintainPartsWork> partsList;

	public void setEmerProcType(Integer emerProcType) {
		if(Func.isNotEmpty(emerProcType)){
			this.emerProcTypeName = EmerProcTypeEnum.getName(emerProcType);
		}
		this.emerProcType = emerProcType;
	}

	public void setWorkOrderType(Integer workOrderType) {
		if(Func.isNotEmpty(workOrderType)){
			this.workOrderTypeName = WorkOrderTypeEnum.getName(workOrderType);
		}
		this.workOrderType = workOrderType;
	}

	public void setStatus(Integer status) {
		this.status = status;
		if(Func.isNotEmpty(status)){
			this.statusName = TaskStatusEnum.getTaskName(MaintainPlanContentEnum.MAINTAIN_PARTS.getId(), status);
		}
	}

	public void setAuditStatus(Integer auditStatus) {
		if(Func.isNotEmpty(auditStatus)){
			this.auditStatusName = ApproveStatusEnum.getName(auditStatus);
		}
		this.auditStatus = auditStatus;
	}
}
